#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time   : 2021/7/25 19:37
# @Author : cjw
from datetime import datetime
from sqlalchemy import Column, Integer, String, Boolean, DateTime, Enum, Text

from app.db.session import Base


class News(Base):
    """新闻模型"""
    __tablename__ = 'news'

    id = Column(Integer, primary_key=True)
    title = Column(String(200), nullable=False, comment='标题')
    img_url = Column(String(200), nullable=False, comment='主图地址')
    content = Column(Text, nullable=False, comment='新闻内容')
    news_type = Column(Enum('本地', '百家', '娱乐', '军事'), comment='新闻类别')
    is_valid = Column(Boolean, default=True, comment='逻辑删除')
    is_top = Column(Boolean, default=False, comment='是否置顶')
    create_at = Column(DateTime, default=datetime.now(), comment='创建时间')
    updated_at = Column(DateTime, default=datetime.now(), comment='最后修改时间')
